﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using EntidadesCompartidas;

namespace Smart_House_System.Cliente
{
    
    public partial class Cliente : System.Web.UI.MasterPage
    {

        private Usuario x;
        protected void Page_Load(object sender, EventArgs e)
        {
            try     
            {
                x = (Usuario)Session["Usuario"];
                if (x == null)
                {
                    Response.Redirect("~/loggueo.aspx");
                }
                else
                {
                    if (x.ElRol == RolUsuario.habPrincipal)
                    {
                        lnkABMUsuarios.Visible = true;
                    }
                    else
                    {
                        lnkABMUsuarios.Visible = false;
                    }
                }
            }
            catch
            {
                Response.Redirect("~/loggueo.aspx");
            }
        }

        protected void lnkCerrarSesion_Click(object sender, EventArgs e)
        {
            Session["Usuario"] = null;
            Response.Redirect("~/loggueo.aspx");
        }

        protected void lnkABMUsuarios_Click(object sender, EventArgs e)
        {
            Response.Redirect("~/Cliente/ABMUsuarios.aspx");
        }

        protected void btnHome_Click(object sender, EventArgs e)
        {
            Response.Redirect("~/Cliente/homecliente.aspx");
        }
    }
}